package jUnitTest;

import static org.junit.Assert.*;

import mvc.ObserverManager;

import org.junit.Test;

import depot.DimensionFormatException;
import depot.DuplicateIDException;
import depot.IDFormatException;
import depot.ParcelMap;


public class CalculationTest {
	
	private ParcelMap parcelmap = new ParcelMap();
	private ObserverManager manager_parcel = new ObserverManager();
	
	@Test
	/**
	 * test the range of data for calculation 
	 * @throws DuplicateIDException whether there is duplicate id
	 * @throws IDFormatException  the format of parcelID
	 * @throws DimensionFormatException the format of dimension
	 */
	public void testCalculation() throws DuplicateIDException, IDFormatException, DimensionFormatException{
		
		String expected1 = String.valueOf(3.7);
		String message1 = "Fail for Calculation: ('L202',5,3,'2.3x4.3x4.5')";
		String actual1 = String.valueOf(manager_parcel.parcelFee("L202", 5, 3));
		assertEquals(message1, expected1, actual1);
		
		String expected2 = String.valueOf(4.5);
		String message2 = "Fail for Calculation: ('L202',5,5)";
		String actual2 = String.valueOf(manager_parcel.parcelFee("L202", 5, 5));
		assertEquals(message2, expected2, actual2);
				
		String expected4 = String.valueOf(6.7);
		String message4 = "Fail for Calculation: ('L202',5,7";
		String actual4 = String.valueOf(manager_parcel.parcelFee("L202", 5, 7));
		assertEquals(message4, expected4, actual4);
		
		String expected5 = String.valueOf(10.5);
		String message5 = "Fail for Calculation: ('L202',5,10";
		String actual5 = String.valueOf(manager_parcel.parcelFee("L202", 5, 10));
		assertEquals(message5, expected5, actual5);
		
		String expected6 = String.valueOf(11.3);
		String message6 = "Fail for Calculation: ('L202',5,11";
		String actual6 = String.valueOf(manager_parcel.parcelFee("L202", 5, 11));
		assertEquals(message6, expected6, actual6);
		
		String expected7 = String.valueOf(18.0);
		String message7 = "Fail for Calculation: ('L202',20,10)";
		String actual7 = String.valueOf(manager_parcel.parcelFee("L202", 20, 10));
		assertEquals(message7, expected7, actual7);		

		String expected8 = String.valueOf(1.6);
		String message8 = "Fail for Calculation: ('N202',5,3";
		String actual8 = String.valueOf(manager_parcel.parcelFee("N202", 5, 3));
		assertEquals(message8, expected8, actual8);
		
		String expected9 = String.valueOf(2.0);
		String message9 = "Fail for Calculation: ('N202',5,5";
		String actual9 = String.valueOf(manager_parcel.parcelFee("N202", 5, 5));
		assertEquals(message9, expected9, actual9);
		
		String expected10 = String.valueOf(4.2);
		String message10 = "Fail for Calculation: ('N202',5,8)";
		String actual10 = String.valueOf(manager_parcel.parcelFee("N202", 5, 8));
		assertEquals(message10, expected10, actual10);
		
		String expected11 = String.valueOf(7.0);
		String message11 = "Fail for Calculation: ('N202',5,10)";
		String actual11 = String.valueOf(manager_parcel.parcelFee("N202", 5, 10));
		assertEquals(message11, expected11, actual11);
		
		String expected12 = String.valueOf(7.6);
		String message12 = "Fail for Calculation: ('N202',5,11)";
		String actual12 = String.valueOf(manager_parcel.parcelFee("N202", 5, 11));
		assertEquals(message12, expected12, actual12);
		
		String expected13 = String.valueOf(10.0);
		String message13 = "Fail for Calculation: ('N202',20,10')";
		String actual13 = String.valueOf(manager_parcel.parcelFee("N202", 20, 10));
		assertEquals(message13, expected13, actual13);
		
		String expected15 = String.valueOf(50.0);
		String message15 = "Fail for Calculation: ('L001',15,60,'2.3x4.3x4.5')";
		String actual15 = String.valueOf(manager_parcel.parcelFee("L001", 15, 60));
		assertEquals(message15, expected15, actual15);
		
		String expected16 = String.valueOf(20.0);
		String message16 = "Fail for Calculation: ('N202',10,50')";
		String actual16 = String.valueOf(manager_parcel.parcelFee("N202",10, 50));
		assertEquals(message16, expected16, actual16);
		
		}
}
